<?php

/* @var $this yii\web\View */
use yii\helpers\Html;
use yii\helpers\Url;
use yii\grid\DataColumn;
$this->title = 'My Yii Application';
?>
<div class="site-index">
        <?php

        Html::a('测试a链接',Url::toRoute(['site/index', 'src'=>'a', 'adf'=>'test'], true), ['id'=>'idtest', 'class'=>'idclass', 'style'=>['color'=>'red'] ]);
        ?>

    <div class="body-content">
        <div class="row listbox" style="border: 0px;">
            <div class="list-group">

                <?php

                echo yii\grid\GridView::widget([
                    'dataProvider' => $provider,
                    'columns' => [
//                        ['class' => 'yii\grid\SerialColumn'],
                          [
                              'class' => DataColumn::className(), // this line is optional
                              'attribute' => 'id',
                              'format' => 'html',
                              'label' => '编号',
                          ],
                        'title',
                        'content',
                        'create_time:datetime',

                        ['class' => 'yii\grid\ActionColumn',
                            'header' => '操作',
                            'options' => ['width' => '100px;'],
                            'template' => '{view} {update} {area} {delete}',
                            'buttons' => [
                                'view' => function ($url, $model) {
                                    return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $url, [
                                        'title' => Yii::t('app', '查看'),
                                    ]);
                                },
                                'update' => function ($url, $model) {
                                    return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [
                                        'title' => Yii::t('app', '更新'),
                                    ]);
                                },
                                'area' => function ($url, $model) {
                                    return Html::a('<span class="glyphicon glyphicon-list"></span>', $url, [
                                        'title' => Yii::t('app', '组合'),
                                    ]);
                                },
                                'delete' => function ($url, $model) {
                                    return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [
                                        'title' => Yii::t('app', '删除'),
                                        'data-confirm'=>'确定删除吗',
                                        ''
                                    ]);
                                },
                                'export' => function ($url, $model) {
                                    if($model->status==0){
                                        return Html::a('导出 Excel', $url, [
                                            'class' => 'btn btn-success',
                                        ]);
                                    }
                                    return null;
                                },
                                'use' => function ($url, $model) {
                                    if($model->status==2){
                                        return Html::a('投入使用', $url, [
                                            'class' => 'btn btn-info',
                                            'data' => [
                                                'confirm' => "确认要投入使用吗？",
                                                'method' => 'post',
                                            ],
                                        ]);
                                    }
                                    return null;
                                },

                            ],
                            'urlCreator' => function ($action, $model, $key, $index) {
                                if ($action === 'view') {
                                    return ['view', 'id' => $model->id];
                                } else if ($action === 'update') {
                                    return ['update', 'id' => $model->id];
                                } else if ($action === 'area') {
                                    return ['area/index', 'group_id' => $model->id];
                                } else if ($action === 'delete') {
                                    return ['delete', 'id' => $model->id];
                                }
                            }
                        ],
                    ],
                ]);
                ?>







                <?php foreach ($list as $key=>$value):?>
                <a href="##" class="list-group-item"><span class="badge">12</span>测试测试</a>
                <?php endforeach;?>
            </div>
        </div>
    </div>
</div>

<?php




?>
